Repository navigation
feat: 打印/导出时只保留题目配图,不包含拍照原图 / exclude photo imports from print & export, keep question figures only - #46
Open
1288893 wants to merge 3 commits into
Open
feat: 打印/导出时只保留题目配图,不包含拍照原图 / exclude photo imports from print & export, keep question figures only#461288893 wants to merge 3 commits into
1288893 wants to merge 3 commits into
Conversation
margrop
requested changes
Nov 27, 2026
margrop
left a comment
Owner
There was a problem hiding this comment.
感谢贡献!打印/导出只保留题目配图、备份导入预检以及 Windows 路径修复都是很实用的改进。
不过当前分支里混入了多个相互独立的改动,且部分代码存在需要修复的问题,建议先调整后再合入:
1. 请按功能拆分 PR
当前 PR 标题和说明对应的是第一个提交(006c77c3,打印/导出配图),但后续又推送了 5 个与该主题无关的提交。建议本 PR 只保留打印/导出配图相关改动,其余有价值的改动单独开 PR,便于逐个审查和合入。
2. 本 PR(打印/导出配图,006c77c3)需确认的点
整体实现和单测写得比较清晰,有以下三点希望确认:
- 默认打印模式变更:
src/lib/print/print-preview-options.ts将DEFAULT_PRINT_OPTIONS.showQuestionText从false改为了true,这会改变新用户首次打印预览的默认模式(原图 → 文字),但 PR 描述未提及,请确认是否必要并在说明中写明。 - 历史带图题目的配图兜底:
src/components/print-preview/printable-question.tsx直接移除了无配图时回退显示originalImage的逻辑。对于历史上拍照导入、hasFigure === true但尚未生成figureSvg或裁剪figureImage的老题目,文字模式下会出现“如图所示”却没有图的情况,建议评估是否需要保留针对hasFigure的兜底或提示。 - JSON 导出行为一致性:
src/components/error-list/export-questions-dialog.tsx在非 Word 格式时传了includeFigures: false,但fromErrorItem仍无条件导出figureSvg,且parse.ts/schema.ts已支持figureImage/figureSource。建议明确 JSON 导出是否需要同步支持或注明差异。
3. 其余提交的建议(拆分 PR 时参考)
58f6c513(scripts/copy-pdfjs-assets.mjsWindows 路径修复):改动干净且有价值,欢迎直接拆成独立fixPR。b35c0a0a(备份「导入全部」缺用户预检):很实用,欢迎拆成独立fixPR,建议同时在src/__tests__/integration/data-backup.test.ts补充对应测试用例。6d2dc9b4(练习列表着色/筛选 + 错题卡片进度):拆分提 PR 前建议完善以下细节并补充测试:src/app/api/practice/questions/route.ts中findIdsByLastResult只匹配r.result = ${result},未兼容历史记录中result为NULL仅存isCorrect的情况(前端practice-history.tsx已兼容);另外not_attempted在卡片上归为黄色,但筛选「作错」时不包含,语义不太一致;全量取 ID 再拼id: { in: lastResultIds }在数据量较大时也存在 SQLite 参数数量上限风险。src/app/api/error-items/list/route.ts中loadPracticeStats建议排除source: 'duplicate_import'(参考weak-tags接口),并确认not_attempted是否应计入作答总数total。src/components/error-list/error-item-card.tsx对未练习过的题目也常驻显示 4 个红色0/0,视觉上较刺眼,建议未练习时使用中性色或按需展示。
20991301/738caeeb(LINUX.md/install.sh/start.sh):仓库已有packaging/和doc/维护安装包与部署文档,不建议在根目录新增这套脚本;此外脚本本身存在几处必现问题,建议直接移除:start.sh使用: "${PORT:-3000}"/: "${HOST:-0.0.0.0}"(:-只展开不赋值,应为:=),在set -u下未传环境变量时会直接报unbound variable退出。install.sh编译产物在dist-scripts/scripts/*.js,但start.sh调用的是dist-scripts/*.js(少了scripts/层级),且因|| true被静默忽略。install.sh文档写的是大写NPM_REGISTRY,但脚本内读取的是小写${npm_registry:-...},环境变量不会生效。install.sh将NEXTAUTH_SECRET写入.env,而start.sh读写.nextauth_secret并导出覆盖,两处不一致。
清理分支并调整后,欢迎再 @ 我复审!
- 打印:历史题目标记了 hasFigure 但尚未生成 SVG/裁剪配图时, 文字模式回退显示拍照原图,避免「如图所示」却没有图 - 导出:includeFigures 同时控制 figureSvg / figureImage / figureSource, 开关与导出内容一致;JSON 作为数据交换格式始终保留题目配图
1288893
force-pushed
the
feat/print-export-figure-only-v2
branch
from
November 28, 2026 12:09
738caee to
81d61f3
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题描述 / Problem
打印预览和导出 Word 时,会把用户拍照导入的原始照片(
originalImageUrl)一并输出,导致打印内容冗余、浪费纸张。学生整理错题本时,只需要题目自带的配图,不需要原始拍照。
When printing or exporting to Word, the app includes the original photo imported
by the user (
originalImageUrl), which is redundant and wastes paper/space.Students only need the clean typeset question with its embedded diagram — not the raw photo.
改动说明 / Changes
打印预览 / Print Preview (
/print-preview)figureImage/figureSvg(题目自带配图)originalImageUrlwhen no structured figure existsfigureImage/figureSvg(question-embedded figures)Word 导出 / Word Export (
.docx)includeFigures选项(默认开启),用于嵌入题目配图includeImages(拍照原图)默认改为关闭includeFiguresoption (default: true) to embed question figuresincludeImages(original photo) now defaults to false国际化 / i18n
zh.ts和en.ts新增includeFigures相关文案zh.tsanden.tswith new keys forincludeFigures测试 / Tests
printable-question、from-error-item、to-docx的单元测试printable-question,from-error-item,to-docx